package com.tax.infrastructure.extension;

import com.tax.config.exception.BusinessException;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;

/**
 * duandehui
 * ExtensionRepository
 */
@Component
public class ExtensionRepository {

    /**
     * 拓展注册库容器
     */
    private Map<ExtensionCoordinate,ExtensionPointI> extensionRepo=new HashMap<>();

    public ExtensionPointI put(ExtensionCoordinate extensionCoordinate,ExtensionPointI extensionPointI) {
        if (extensionRepo.containsKey(extensionCoordinate)){
            throw new BusinessException("Duplicate registration is not allowed for :"+extensionCoordinate);
        }
        return extensionRepo.put(extensionCoordinate,extensionPointI);
    }

    public ExtensionPointI get(ExtensionCoordinate extensionCoordinate){
        return extensionRepo.get(extensionCoordinate);
    }
}
